package cn.tedu._05springmvc01.controller;

import cn.tedu._05springmvc01.pojo.dto.UserWeightLossDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    @RequestMapping("/bmi")
    @ResponseBody
    public String weightLoss(UserWeightLossDTO weightLossDTO) {
        Double weight = weightLossDTO.getWeight();
        Double height = weightLossDTO.getHeight();
        if (weight / (height * height) >= 27) {
            return "该减肥了";
        }
        if (weight / (height * height) < 27 && weight / (height * height) >= 24) {
            return "微胖";
        }
        if (weight / (height * height) < 24 && weight / (height * height) >= 18.5){
            return "正常";
        }
            return "偏瘦";
    }
}
